<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>String对象</title>
    <link rel="shortcut icon" href="../../../../favicon.ico" type="image/x-icon">
    <link rel="stylesheet" href="../../css/datatype.css">
</head>

<body>
    <div id="nav">
        <ul>
            <li><a href="./math.html">Math</a></li>
            <li><a href="./string.html">String</a></li>
            <li><a href="./object.html">Object</a></li>
            <li><a href="./array.html">Array</a></li>
            <li><a href="./date.html">Date</a></li>
        </ul>
        <div id="back">
            <a href="../../index.html">返回首页</a>
        </div>
    </div>
    <div class="container">
        <div>
            <label>String A:
                <input id="radio-a" type="radio" checked="true" name="str-obj" value="a">
            </label>
            <textarea id="str-a"></textarea><br>
            <label>String B:
                <input id="radio-b" type="radio" name="str-obj" value="b">
            </label>
            <textarea id="str-b"></textarea><br>
            <label>Num A：<input id="num-a" type="number" value="0"></label>
            <label>Num B：<input id="num-b" type="number" value="1"></label>
        </div>
        <div>
            <button>获取当前选中输入的内容长度</button>
            <button>当前选中输入中的第3个字符</button>
            <button>把两个输入框的文字连接在一起输出（concat）</button>
            <button>输入B中的内容，在输入A的内容中第一次出现的位置（indexOf）</button>
            <button>输入A中的内容，在输入B的内容中最后一次出现的位置（lastIndexOf）</button>
            <button>使用slice获取选中输入框内容的部分内容，参数为num-a及num-b</button>
            <button>当前选中输入框的行数</button>
            <button>使用substr获取选中输入框内容的子字符串，参数为num-a及num-b</button>
            <button>把所选输入框中的内容全部转为大写</button>
            <button>把所选输入框中的内容全部转为小写</button>
            <button>把所选输入框中内容的半角空格全部去除</button>
            <button>把所选输入框中内容的a全部替换成另外一个输入框中的内容</button>
        </div>
        <p id="result"></p>
        <hr>
        <h2>去除空格大作战</h2>
        <ul class="space">
            <li>测试用例如下，复制粘贴到console中查看结果</li>
            <li><span class="case">console.log(diyTrim(' a f b '));</span> // -> <span class="answer">a f b</span></li>
            <li><span class="case">console.log(diyTrim(' ffdaf '));</span> // -> <span class="answer">ffdaf</span></li>
            <li><span class="case">console.log(diyTrim('1 '));</span> // -> <span class="answer">1</span></li>
            <li><span class="case">console.log(diyTrim('　　f'));</span> // -> <span class="answer">f</span></li>
            <li><span class="case">console.log(diyTrim(' 　 a f b 　　 '));</span> // -> <span class="answer">a f b</span></li>
            <li><span class="case">console.log(diyTrim(' '));</span> // -> <span class="answer"></span></li>
            <li><span class="case">console.log(diyTrim('　'));</span> // -> <span class="answer"></span></li>
            <li><span class="case">console.log(diyTrim(''));</span> // -> <span class="answer"></span></li>
        </ul>
        <hr>
        <h2>去除重复大作战</h2>
        <ul class="space">
            <li>测试用例如下，复制粘贴到console中查看结果</li>
            <li><span class="case">console.log(removeRepetition("aaa"));</span> // -> <span class="answer">a</span></li>
            <li><span class="case">console.log(removeRepetition("abbba"));</span> // -> <span class="answer">aba</span></li>
            <li><span class="case">console.log(removeRepetition("aabbaabb"));</span> // -> <span class="answer">abab</span></li>
            <li><span class="case">console.log(removeRepetition(""));</span> // -> <span class="answer"></span></li>
            <li><span class="case">console.log(removeRepetition("abc"));</span> // -> <span class="answer">abc</span></li>
        </ul>
    </div>

    <script src="../../js/datatype.js"></script>
    <script src="../../js/string.js"></script>
</body>

</html>